<?php
    date_default_timezone_set('UTC');
?>
<div class="well" >
    <div class="row-fluid">
        <div class="span6"><b><a href="<?php echo $view->url(array('controller' => 'ExpenditureTypes', 'action' => 'index')); ?>">Volver a Tipos de Gastos </a></b></div>
        <div class="span6 derecha hide"><b><?php echo $view->fecha; ?></b></div>
        </div>
        <div class="row-fluid centrar">
      
        <h3>Editar Tipo de Gasto</h3>
        
    </div><br/>
    <div class="contenido contexto">
  <form id="principal">
       <input type="hidden" name="expenditureId" id="expenditureId" value="<?php echo $view->idexpenditure; ?>"  />
             <div class="row-fluid">
  			 <div class="span8">
                <div class="span2">Nombre:</div>
                <div class="span10"><input type="text" class="span12" id="nameexpenditure" name="nameexpenditure" onkeypress="return validar(event, 'letra')" value="<?php echo $view->name; ?>" /></div>
         </div>
         </div>
         
             <div class="row-fluid">
			 <div class="span8">
               <div class="span2">Descripción:</div>
               <div class="span10"><textarea id="description" name="description"  class="span12"><?php echo $view->description; ?></textarea></div>
         </div>
      </div>
      
       <div class="row-fluid">
			 <div class="span8">
               <div class="span2">Fecha:</div>
               <div class="span10"><input type="text" readonly="readonly" id="date_in" name="date_in"  class="span12"/  value="<?php echo $view->date; ?>"  /></div>
         </div>
      </div>
      		
  </form>          
    </div>
    <br/>
    <div class="contexto centrar">
            <div class="row-fluid">
                <input type="button" class="k-button" name="btnEditExpenditure"  onclick="saveExpenditureTypes(this.name)" value="Guardar"/>
                <input type="button" class="k-button" name="btnCancel" data-bind="click: cancel" value="Cancelar"/>
            </div>
       
</div>
<script type="text/javascript">

/* funcion para insertar solo letras*/
function  validar(e,modo){
tecla = (document.all)? e.keyCode : e.which;
patron=(modo=='letra') ?  /[a-zA-Zs ]/ : /[0-9]/
te=String.fromCharCode(tecla);
return patron.test(te);
}

function redirect()
	{
		location.href="<?php echo $view->url(array('controller' => 'ExpenditureTypes', 'action' => 'index')); ?>";
	}


 function saveExpenditureTypes(v)
 {
	 var param = $("#nameexpenditure").val() + "*"  + $("#description").val() + "*"  + $("#date_in").val() + "!" + v + "!" + $("#expenditureId").val();
           $.ajax({
          type: "POST",
          data: 'form=' + param,
          url: "<?php echo $view->url(array('controller' => 'ExpenditureTypes', 'action' => 'saveExpenditureTypes')); ?>",
		  success: function (res){
                 				alert(res)
                            }
         });
		 location.href="<?php echo $view->url(array('controller' => 'ExpenditureTypes', 'action' => 'index')); ?>";
	 }
</script>



























